package com.hyfrogx.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.modules.app.dao.AttentionDao;
import com.hyfrogx.modules.app.entity.HyUserAttentionEntity;
import com.hyfrogx.modules.app.service.AttentionService;
import com.hyfrogx.modules.information.entity.HyInformationEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liubin
 * @date 2019/10/28 13:15
 */
@Service("AttentionService")
@Slf4j
public class AttentionServiceImpl extends ServiceImpl<AttentionDao, HyUserAttentionEntity> implements AttentionService {

  @Override
  public List<HyUserAttentionEntity> getAllFollowId(Long userId) {
    return getBaseMapper().getAllFollowId(userId);
  }

  @Override
  public Page getMyFunsByUid(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyUserAttentionEntity> result =this.baseMapper.getMyFunsByUid(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public Page getAllSunSid(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyUserAttentionEntity> result =this.baseMapper.getAllSunSid(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public HyUserAttentionEntity getBySidAndUid(Integer sid, Integer uid) {
    return this.baseMapper.getBySidAndUid(sid,uid);
  }

  @Override
  public Page getAllFunsId(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyUserAttentionEntity> result =this.baseMapper.getAllFunsId(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public Integer selectsta(Integer sid, Integer fid) {
    HyUserAttentionEntity bySidAndUid = this.baseMapper.getBySidAndUid(sid,fid);
    Integer sta=1;
    if(bySidAndUid==null){
      sta=0;
    }else{
      sta=1;
    }
    return sta;  }

  @Override
  public HyUserAttentionEntity getByFid(Integer userId) {
    return this.baseMapper.getByFid(userId);
  }
}
